package com.cn.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.cn.conn.DataManager;
import com.cn.conn.ParamSet;
import com.cn.conn.RowDatas;
	
/**
 * 登录dao层
 * @author dell1
 *
 */

public class LoginDao extends DataManager {
	private RowDatas<String > userpw;//用户密码
	private RowDatas<String > username;//用户名字
	
	public  LoginDao(){
		userpw = new Userpw();
		username = new Username();
	}
	
	public String Getuserpw(String phon){
		String  sql="SELECT `password` FROM tb_user WHERE phone=?";
		return query(sql, new ParamSet(phon), userpw);
	}
	public String Getusername(String phon){
		String  sql="SELECT `name` FROM tb_user WHERE phone=?";
		return query(sql, new ParamSet(phon), username);
	}
	
	/**
	 * 通过内部类完成整型数据处理
	 * @author Administrator
	 *
	 */
	private class Userpw implements RowDatas<String>{

		@Override
		public String getRowData(ResultSet rs) throws SQLException {
			return rs.getString(1); 
		}		
	}
	
	private class Username implements RowDatas<String>{

		@Override
		public String getRowData(ResultSet rs) throws SQLException {
			return rs.getString(1); 
		}		
	}
}
